/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * <p>Project: javase - Ex2
 * <p>Powered by webrx On 2021-11-24 09:29:00
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex2 {
    public static void main(String[] args) throws ParseException {
        System.out.printf("%1$tF %1$tT %n", 0l);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for (int i = 0; i <= 15; i++)
            System.out.printf("%1$tF %1$tT %n", nextLong(sdf.parse("2021-01-01 00:00:00").getTime(), new Date().getTime()));
    }

    /**
     * 静态方法，用于生成指定范围的long
     *
     * @param a
     * @param b
     * @return
     */
    public static long nextLong(long a, long b) {
        var rand = new Random();
        return (long) (rand.nextDouble() * (b - a + 1) + a);
    }
}
